/**
 * 
 */
package com.nwpusp.controller.actions;

import com.nwpusp.model.GameModel;
import com.nwpusp.model.characters.GameCharacter;
import com.nwpusp.model.session.ConnectionId;

/**
 * @author JustinCao
 *
 */
public class CharacterAction extends Action {

	public enum ActionType {none, jump, laydown, trackMove, trackShift}
	private ActionType actionType = ActionType.none;
	private ConnectionId cid = null;
	private int actionValue = 0;
	
	public CharacterAction(ConnectionId cid, ActionType actionType, int actionValue) {
		this.cid = cid;
		this.actionType = actionType;
		this.actionValue = actionValue;
	}

	@Override
	public void Invoke(GameModel m) {
		GameCharacter ch = m.getPlayerManager().getPlayer(cid).getCh();
		switch(actionType) {
		case jump:
			if(ch.getStatus() == GameCharacter.CHARACTERSTS_Running) {
				ch.startJump();
			}
			break;
		case laydown:
			if(ch.getStatus() == GameCharacter.CHARACTERSTS_Running) {
				ch.startLaydown();
			}
			break;
		case trackMove:
			if(ch.getStatus() == GameCharacter.CHARACTERSTS_Running) {
				ch.trackDirectionMove(actionValue);
			}
			break;
		case trackShift:
			if(ch.getStatus() == GameCharacter.CHARACTERSTS_Running) {
				ch.trackShift(actionValue);
			}
			break;
		default:
			break;
		}
	}

}
